<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitepage
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: index.tpl 2011-05-05 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
?>

<ul class="sitepage_categories_block">
  <li>
    <?php $ceil_count = 0;
    $k = 0;
    $sitepage_categories_name = Zend_Registry::isRegistered('sitepage_category_type') ? Zend_Registry::get('sitepage_category_type') : null; ?>
    <?php for ($i = 0; $i <= count($this->categories); $i++) { ?>
    <?php if($ceil_count == 0) :?>
      <div>
    <?php endif;?>
    <div class="sitepage_categories_sitepage_col">
      <?php $ceil_count++; ?>
        <?php $category = "";
        if (isset($this->categories[$k]) && !empty($this->categories[$k])): $category = $this->categories[$k];
        endif;
        $k++; ?>
          <?php
          if (empty($category) && !empty($sitepage_categories_name)) {
            break;
          }
          ?>
          <div class="sitepage_categories_sitepage">
            <?php $total_subcat = count($category['sub_categories']); ?>
            <h6>
              <?php echo $this->htmlLink($this->url(array('category_id' => $category['category_id'], 'categoryname' => Engine_Api::_()->getDbTable('categories', 'sitepage')->getCategorySlug($this->translate($category['category_name']))), 'sitepage_general_category'), $this->translate($category['category_name'])) ?>
                (<?php echo $category['count'] ?>)
            </h6>
            <div class="sub_cat" id="subcat_<?php echo $category['category_id'] ?>">
              <?php foreach ($category['sub_categories'] as $subcategory) : ?>
                <?php $subcategoryname = '<img src="./application/modules/Sitepage/externals/images/gray_bullet.png" alt=""><b>' . $this->translate($subcategory['sub_cat_name']) . ' (' . ($subcategory['count']) . ') </b>' ; ?>
                <?php echo $this->htmlLink($this->url(array('category_id' => $category['category_id'], 'categoryname' => Engine_Api::_()->getDbTable('categories', 'sitepage')->getCategorySlug($this->translate($category['category_name'])), 'subcategory_id' => $subcategory['sub_cat_id'], 'subcategoryname' => Engine_Api::_()->getDbTable('categories', 'sitepage')->getCategorySlug($this->translate($subcategory['sub_cat_name']))), 'sitepage_general_subcategory'), $this->translate($subcategoryname)) ?>
                <?php if(!empty($this->show3rdlevelCategory)):?>
                  <?php if(isset($subcategory['tree_sub_cat'])):?>
                    <?php foreach ($subcategory['tree_sub_cat'] as $subsubcategory) : ?>
                      <?php $subsubcategoryname = '<img src="./application/modules/Sitepage/externals/images/gray_arrow.png" alt="">' . $this->translate($subsubcategory['tree_sub_cat_name']) . ' (' . ($subsubcategory['count']) . ') '; ?>
                      <?php echo $this->htmlLink($this->url(array('category_id' => $category['category_id'], 'categoryname' => Engine_Api::_()->getDbTable('categories', 'sitepage')->getCategorySlug($this->translate($category['category_name'])), 'subcategory_id' => $subcategory['sub_cat_id'], 'subcategoryname' => Engine_Api::_()->getDbTable('categories', 'sitepage')->getCategorySlug($this->translate($subcategory['sub_cat_name'])),'subsubcategory_id' => $subsubcategory['tree_sub_cat_id'], 'subsubcategoryname' => Engine_Api::_()->getDbTable('categories', 'sitepage')->getCategorySlug($this->translate($subsubcategory['tree_sub_cat_name'])),), 'sitepage_general_subsubcategory'), $this->translate($subsubcategoryname)) ?>
                    <?php endforeach; ?>
                   <?php endif;?>
               <?php endif;?>
              <?php endforeach; ?>
            </div>
          </div>
      </div>
     <?php if($ceil_count %3 == 0) :?>
     </div>
     <?php $ceil_count=0; ?>
     <?php endif;?>
    <?php } ?>
  </li>
</ul>